<script setup lang="ts">
import { ref } from 'vue'
import * as iconList from '@element-plus/icons-vue'

defineProps({
  modelValue: String
})
const emit = defineEmits(['update:modelValue'])
const icons = ref(Object.keys(iconList))
function handleChange(icon) {
  emit('update:modelValue', icon)
}
</script>

<template>
  <div style="display: flex; align-items: center">
    <el-icon v-if="modelValue" :size="22" color="blue"><component :is="modelValue" /></el-icon>
    <el-select
      :modelValue="modelValue"
      placeholder="选择图标"
      @change="handleChange"
      filterable
      style="width: 180px; margin-left: 10px"
    >
      <el-option v-for="item in icons" :key="item" :label="item" :value="item">
        <div style="display: flex; align-items: center; justify-content: space-between">
          <el-icon><component :is="item" /></el-icon>
          <span style="color: #666">{{ item }}</span>
        </div>
      </el-option>
    </el-select>
  </div>
</template>

<style lang="scss" scoped>
/*  */
</style>
